﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace job
{
    public partial class company_zhaopin : Form
    {
        public company_zhaopin()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1zcno.Text != "" && textBox2zname.Text != "" && textBox3zjob.Text != "" && textBox4zphone.Text != "" && textBox5znumber.Text != "")
            {
                Dao dao = new Dao();
                string sql = $"insert into company_zhaopin values ('{textBox1zcno.Text}','{textBox2zname.Text}','{textBox3zjob.Text}',{textBox4zphone.Text},'{textBox5znumber.Text}')";
                //string sql = $"insert into company_zhaopin values ('{textBox1zcno.Text}',{textBox2zname}','{textBox3zjob}','{textBox4zphone}','{textBox5znumber}')"; //int型单引号可以不要
                //string sql = string.Format("insert into company_zhaopin values('{0}','{1}','{2}','{3}','{4}')",textBox1zcno.Text,textBox2zname.Text,textBox3zjob.Text,textBox4zphone.Text,textBox5znumber);
                int n = dao.Execute(sql);//添加的值传回dao
                if (n > 0)
                {
                    MessageBox.Show("添加成功");

                }
                else
                {
                    MessageBox.Show("添加失败");
                }
                textBox1zcno.Text = ""; //增加后清空文本框
                textBox2zname.Text = "";
                textBox3zjob.Text = "";
                textBox4zphone.Text = "";
                textBox5znumber.Text = "";


            }
            else
            {
                MessageBox.Show("你的输入有空，请重新输入");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
